package com.docmanage.am.service.impl;

import java.util.List;

import com.docmanage.am.mapper.AmApprovalMapper;
import com.docmanage.common.utils.DateUtils;
import org.springframework.stereotype.Service;
import com.docmanage.am.domain.AmApproval;

import javax.annotation.Resource;

/**
 * 审批Service业务层处理
 * 
 * @author docmanage
 * @date 2023-12-03
 */
@Service
public class AmApprovalService
{
    @Resource
    private AmApprovalMapper amApprovalMapper;

    /**
     * 查询审批
     * 
     * @param id 审批主键
     * @return 审批
     */

    public AmApproval selectAmApprovalById(Long id)
    {
        return amApprovalMapper.selectAmApprovalById(id);
    }

    /**
     * 查询审批列表
     * 
     * @param amApproval 审批
     * @return 审批
     */

    public List<AmApproval> selectAmApprovalList(AmApproval amApproval)
    {
        return amApprovalMapper.selectAmApprovalList(amApproval);
    }

    /**
     * 新增审批
     * 
     * @param amApproval 审批
     * @return 结果
     */

    public int insertAmApproval(AmApproval amApproval)
    {
        amApproval.setCreateTime(DateUtils.getNowDate());
        return amApprovalMapper.insertAmApproval(amApproval);
    }

    /**
     * 修改审批
     * 
     * @param amApproval 审批
     * @return 结果
     */

    public int updateAmApproval(AmApproval amApproval)
    {
        amApproval.setUpdateTime(DateUtils.getNowDate());
        return amApprovalMapper.updateAmApproval(amApproval);
    }

    /**
     * 批量删除审批
     * 
     * @param ids 需要删除的审批主键
     * @return 结果
     */

    public int deleteAmApprovalByIds(Long[] ids)
    {
        return amApprovalMapper.deleteAmApprovalByIds(ids);
    }

    /**
     * 删除审批信息
     * 
     * @param id 审批主键
     * @return 结果
     */

    public int deleteAmApprovalById(Long id)
    {
        return amApprovalMapper.deleteAmApprovalById(id);
    }

    public List<AmApproval> getAmApprovalByBorrowId(Long borrowId) {
       return amApprovalMapper.getAmApprovalByBorrowId(borrowId);
    }

    /**
     * 通过obj_id 删除对应的审批申请
     * @param id
     * @return
     */
    public int deleteApprovalByObjId(Long id) {
       return amApprovalMapper.deleteApprovalByObjId(id);
    }
}
